%This function in necessary for generateHomogeneousState to calculate the homogeneous state vector.
%
%This function in necessary for generateHomogeneousState to calculate the
%homogeneous state vector.
%
%Prototype: [hState] = generateHomogeneousStateRecursive(m, x, varNumber, vect, threshold, hState)
%
%Input:     m - Dimension of the state vector x in homogeneous form.
%           x - State vector
%           varNumber - 
%           vect - Vector that contains the degree of the #varNumber
%                  variables to crate
%           threshold - Number that decrease degree of next homogeneous
%                       monomial variable to create
%           hState - Homogeneous state vector
%
%Output:    hState - Homogeneous state vector

function [ hState ] = generateHomogeneousStateRecursive( m, x, varNumber, vect, threshold, hState )

for i = (m-threshold):-1:0
    vect(varNumber) = i;
    if sum(vect) == m
        if hState(1) == -1
            hState = prod(x.^vect);
        else
            hState(length(hState)+1, 1) = prod(x.^vect);
        end
    else
        if varNumber < length(x)
            hState = generateHomogeneousStateRecursive( m, x, varNumber+1, vect, threshold+i, hState );
        end
    end
end

return;

end

